home *** CD-ROM | disk | FTP | other *** search
/ Stolen Data 2 / Stolen Data 2.adf / Source / Hidden.s < prev    next >
Text File  |  1989-11-02  |  6KB  |  401 lines

  1.     Incdir    Df1:
  2.     Include Source/CustomRegisters
  3.     Section    Hidden,Code_c
  4.  
  5. Ciaapra = $BFE001
  6. Openlibrary = -30-522    
  7. Disable        = -120
  8. Enable        = -126
  9. Startlist   = 38
  10. Execbase = 4
  11.  
  12.     Move.l    Execbase,a6
  13.     Jsr    Disable(a6)
  14.  
  15. ;-------- Switch Copper DMA ----------
  16.  
  17.     Move.l    #Clstart,Cop1lc
  18.     Clr    Copjmp1
  19.  
  20.     Move.w    #$8780,Dmacon
  21.     Move.w    #$0020,Dmacon
  22.     Lea    Spr0data,a0
  23.     Moveq    #7,d0
  24. Clop
  25.     Clr.l    (a0)
  26.     Addq.l    #8,a0
  27.     Dbf    d0,Clop
  28.  
  29. ;------ Wait for Vertical position 1 --------
  30.  
  31. Wait:    Move.l    $dff004,d2
  32.     And.l    #$0001ff00,d2    
  33.     Cmp.l    #$00000100,d2
  34.     Bne.s    Wait
  35.  
  36.     Addq    #2,Zrot
  37.     And    #$1fe,Zrot
  38.     Addq    #4,Yrot
  39.     And    #$1fe,Yrot
  40.     Subq    #2,Xrot
  41.     And    #$1fe,Xrot
  42.     Bsr    TD_rout
  43.  
  44.     Btst    #6,Ciaapra
  45.     Bne    Wait
  46.  
  47. ;------ Restore old Copper list -----------
  48.  
  49.     Move.l    Execbase,a6
  50.     Move.l    #Grname,a1
  51.     Clr.l    d0
  52.     Jsr    Openlibrary(a6)
  53.     Move.l    d0,a4
  54.     Move.l    Startlist(a4),Cop1lc
  55.     Clr.w    Copjmp1
  56.     Move.w    #$83E0,Dmacon
  57.     Jsr    Enable(a6)
  58.     Clr.l    d0
  59.     Rts
  60.  
  61. ;------------ 3D graphics ---------------
  62. TD_rout
  63. ;---------- Clear the current workspace
  64.  
  65.     Move.l    Current(pc),d0
  66.     Move    d0,Screen+2
  67.     Swap    d0
  68.     Move    d0,Screen+6
  69.     Eor.l    #$3000,Current
  70.     Move.l    Current(pc),a0
  71.     Move.l    #$1f00000,Bltcon0
  72.     Move.l    a0,Bltdpth
  73.     Clr    Bltadat
  74.     Clr    Bltdmod
  75.     Move    #256*64+20,Bltsize
  76.  
  77. ;---------- Perform the 3D calculations
  78.  
  79.     Move    #No_points-1,d7
  80.     Lea    Points(pc),a4    
  81.     Lea    Sintable+$40(pc),a1
  82.     Lea    Rotated_coords(pc),a2
  83.     Lea    Perspective(pc),a3
  84. TD_loop
  85.     Move    (a4)+,d0
  86.     Move    d0,d2
  87.     Move    (a4)+,d1
  88.     Move    d1,d3
  89.  
  90.     Move    Zrot(pc),d6
  91.     Move    $40(a1,d6),d4
  92.     Move    -$40(a1,d6),d5
  93.     Muls    d4,d0
  94.     Muls    d5,d1
  95.     Sub.l    d1,d0
  96.     Add.l    d0,d0
  97.     Swap    d0        ;d0 holds intermediate x coord
  98.     Muls    d5,d2
  99.     Muls    d4,d3
  100.     Add.l    d3,d2
  101.     Add.l    d2,d2
  102.     Swap    d2        ;d2 holds intermediate y coord
  103.     Move    d2,d4
  104.  
  105.     Move    (a4)+,d1    ;z coord
  106.     Move    d1,d3
  107.     Move    Xrot(pc),d6
  108.     Move    $40(a1,d6),d5
  109.     Move    -$40(a1,d6),d6
  110.     Muls    d5,d2
  111.     Muls    d6,d1
  112.     Sub.l    d1,d2
  113.     Add.l    d2,d2
  114.     Swap    d2        ;d2 holds the final y coord
  115.     Muls    d5,d3
  116.     Muls    d6,d4
  117.     Add.l    d4,d3
  118.     Add.l    d3,d3
  119.     Swap    d3        ;d3 holds intermediate z coord
  120.  
  121.     Move    d0,d1
  122.     Move    d3,d4
  123.     Move    Yrot(pc),d6
  124.     Move    $40(a1,d6),d5
  125.     Move    -$40(a1,d6),d6
  126.     Muls    d5,d3
  127.     Muls    d6,d0
  128.     Sub.l    d0,d3
  129.     Add.l    d3,d3
  130.     Swap    d3        ;d3 holds the final z coord
  131.     Muls    d6,d4
  132.     Muls    d5,d1
  133.     Add.l    d4,d1
  134.     Add.l    d1,d1
  135.     Swap    d1        ;d1 holds the final x coord
  136.  
  137.     Add    Depth(pc),d3
  138.     Add    d3,d3
  139.     Move    (a3,d3),d5
  140.     Muls    d5,d1
  141.     Muls    d5,d2
  142.     Add.l    d1,d1
  143.     Swap    d1
  144.     Add    #160,d1
  145.     Add.l    d2,d2
  146.     Swap    d2
  147.     Add    #128,d2
  148.     
  149.     Move    d1,(a2)+
  150.     Move    d2,(a2)+
  151.     Dbf    d7,TD_loop
  152.  
  153. ;---------- Plot the surfaces (lines)
  154.  
  155.     Move    #No_connects-1,d7
  156.     Lea    $dff000,a5
  157.     Moveq    #40,d0
  158.     Lea    Bits(pc),a1
  159.     Lea    Connect(pc),a2
  160.     Lea    Rotated_coords(pc),a3
  161.  
  162.     Lea    Faces(pc),a6
  163. B_wait2
  164.     Btst    #14,Dmaconr
  165.     Bne.s    B_wait2
  166.  
  167.     Move    #$ffff,Bltafwm
  168.     Move    d0,$60(a5)    ;Bltcmod
  169.     Move    d0,$66(a5)    ;Bltdmod
  170.     Move    #$ffff,$72(a5)    ;Bltbdat
  171.  
  172.     Move    #No_faces,Face
  173. Draw_loop1
  174.     Move.l    (a6)+,d7
  175.     Move.l    (a6)+,a4
  176.     Move    (a4),d6
  177.     Move    (a2,d6),d4
  178.     Move    2(a2,d6),d5
  179.     Move    (a3,d4),d0
  180.     Sub    (a3,d5),d0
  181.     Move    2(a3,d4),d1
  182.     Sub    2(a3,d5),d1
  183.  
  184.     Move    2(a4),d6
  185.     Move    (a2,d6),d4
  186.     Move    2(a2,d6),d5
  187.     Move    (a3,d4),d2
  188.     Sub    (a3,d5),d2
  189.     Move    2(a3,d4),d3
  190.     Sub    2(a3,d5),d3
  191.  
  192.     Muls    d3,d0
  193.     Muls    d2,d1
  194.  
  195.     Cmp    d0,d1
  196.     Blt.s    Nodraw2
  197.  
  198. Draw_loop2
  199.     Move    (a4)+,d5
  200.     Move    (a2,d5),d6
  201.     Move    (a3,d6),d0
  202.     Move    2(a3,d6),d1
  203.  
  204.     Move    2(a2,d5),d6
  205.     Move    (a3,d6),d2
  206.     Move    2(a3,d6),d3
  207.     Cmp    d0,d2
  208.     Bne.s    Draw
  209.     Cmp    d1,d3
  210.     Beq.s    Nodraw1
  211. Draw
  212.     Bsr    Line
  213. Nodraw1
  214.     Dbf    d7,Draw_loop2
  215. Nodraw2
  216.     Subq    #1,Face
  217.     Tst    Face
  218.     Bne    Draw_loop1
  219. Bwit
  220.     Btst    #14,Dmaconr
  221.     Bne.s    Bwit
  222.     Rts
  223.  
  224. ;----------- Line Draw ------------
  225. Line
  226.     Moveq    #40,d4
  227.     Mulu    d1,d4
  228.     Moveq    #-$10,d5
  229.     And    d0,d5
  230.     Lsr    #3,d5
  231.     Add    d5,d4
  232.     Add.l    a0,d4
  233.  
  234.     Moveq    #0,d5
  235.     Sub    d1,d3
  236.     Roxl.b    d5
  237.     Tst    d3
  238.     Bge.s    Y2gy1
  239.     Neg    d3
  240. Y2gy1
  241.     Sub    d0,d2
  242.     Roxl.b    d5
  243.     Tst    d2
  244.     Bge.s    X2gx1
  245.     Neg    d2
  246. X2gx1
  247.  
  248.     Move    d3,d1
  249.     Sub    d2,d1
  250.     Bge.s    Dygdx
  251.     Exg    d2,d3
  252. Dygdx
  253.     Roxl.b    d5
  254.     Move.b    Octant_table(pc,d5),d5
  255.     Add    d2,d2
  256. Wblit
  257.     Btst    #14,Dmaconr
  258.     Bne.s    Wblit
  259.  
  260.     Move    d2,$62(a5)    ;Bltbmod
  261.     Sub    d3,d2
  262.     Bge.s    Signn1
  263.     Or.b    #$40,d5
  264. Signn1
  265.     Move    d2,$52(a5)    ;Bltaptl
  266.     Sub    d3,d2
  267.     Move    d2,$64(a5)    ;Bltamod
  268.  
  269.     Move    #$8000,$74(a5)    ;Bltadat
  270.     Add    d0,d0
  271.     Move    (a1,d0),$40(a5)    ;Bltcon0
  272.     Move    d5,$42(a5)    ;Bltcon1
  273.     Move.l    d4,$48(a5)    ;Bltcpth
  274.     Move.l    d4,$54(a5)    ;Bltdpth
  275.     Addq    #1,d3
  276.     Lsl    #6,d3
  277.     Addq    #2,d3
  278.     Move    d3,$58(a5)    ;Bltsize
  279.     Rts
  280.  
  281. ;---------- Constants -------------
  282.  
  283. Octant_table
  284.     Dc.b    1,17,9,21,5,25,13,29
  285.  
  286. Grname:    Dc.b    "graphics.library",0
  287.  
  288.     Even
  289.  
  290. ;----------- Variables ------------
  291.  
  292. Xrot    Dc.w    $100
  293. Yrot    Dc.w    0
  294. Zrot    Dc.w    0
  295. Current    Dc.l    $70000
  296. Depth    Dc.w    180
  297. Depthpt    Dc.w    0
  298. Face    Dc.w    0
  299.  
  300. ;---------- Copperlists -----------
  301. Clstart:
  302.     Wait    0,20
  303.     Mov    $1a81,Diwstrt
  304.     Mov    $39c1,Diwstop
  305.     Mov    $0038,Ddfstrt
  306.     Mov    $00d0,Diwstop
  307. Screen
  308.     Mov    0,Bpl1ptl
  309.     Mov    7,Bpl1pth
  310.     Mov    $1200,Bplcon0
  311.     Mov    0,Bpl1mod
  312.     Mov    0,Color00
  313.     Mov    $fff,Color01
  314.     Wait    224,255
  315.     Wait    $fe,$ff
  316.  
  317. ;--------- Binaries -------------
  318. No_points    = 6
  319. No_connects    = 12
  320. No_faces    = 8
  321.  
  322. Points
  323.     Dc.w    100,100,0
  324.     Dc.w    -100,100,0
  325.     Dc.w    -100,-100,0
  326.     Dc.w    100,-100,0
  327.     Dc.w    0,0,150
  328.     Dc.w    0,0,-150
  329.  
  330. Connect
  331.     Dc.w    0,4
  332.     Dc.w    4,8
  333.     Dc.w    8,12
  334.     Dc.w    12,0
  335.  
  336.     Dc.w    0,16
  337.     Dc.w    4,16
  338.     Dc.w    8,16
  339.     Dc.w    12,16
  340.  
  341.     Dc.w    0,20
  342.     Dc.w    4,20
  343.     Dc.w    8,20
  344.     Dc.w    12,20
  345.  
  346. Faces
  347.     Dc.l    2,Face1
  348.     Dc.l    2,Face2
  349.     Dc.l    2,Face3
  350.     Dc.l    2,Face4
  351.     Dc.l    2,Face5
  352.     Dc.l    2,Face6
  353.     Dc.l    2,Face7
  354.     Dc.l    2,Face8
  355.  
  356. Face1    Dc.w    0,20,16
  357.  
  358. Face2    Dc.w    4,24,20
  359.  
  360. Face3    Dc.w    8,28,24
  361.  
  362. Face4    Dc.w    12,16,28
  363.  
  364. Face5    Dc.w    36,0,32
  365.  
  366. Face6    Dc.w    40,4,36
  367.  
  368. Face7    Dc.w    44,8,40
  369.  
  370. Face8    Dc.w    32,12,44
  371.  
  372. Rotated_coords    
  373.     Dcb.w    No_points*2,0
  374. Sintable
  375.     Incbin    Binary/Sin
  376.     Incbin    Binary/Sin
  377. Perspective
  378.     Incbin    Binary/Perspective
  379.  
  380. Mul40
  381. A set 0
  382.     Rept    320
  383.     Dc.w    A*40
  384. A set A+1
  385.     Endr
  386.  
  387. A set 0
  388. Bits
  389.     Rept    320
  390.     Dc.w    ((A&$f)*$1000)+$bca
  391. A set A+1
  392.     Endr
  393.  
  394. Size
  395. A set 0
  396.     Rept    320
  397.     Dc.w    (A*64)+2
  398. A set A+1
  399.     Endr
  400.  
  401.